"Preserve battery health" is a new feature which limits battery
charging in order to increase battery longevity.
Currently when the charging limit is hit, the state is
indistinguishable from the unplugged, discharging state,
which isn't great: The user has no way to know whether
the limit was reached, or they accidentally unplugged
the device.
To address this, use dedicated icons in the plugged-in-
but-not-charging case.
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5228
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3474>
<property name="TimeToFull" type="x" access="read"/>
<property name="IsPresent" type="b" access="read"/>
<property name="IconName" type="s" access="read"/>
+ <property name="ChargeThresholdEnabled" type="b" access="read"/>
</interface>
</node>
return;
// The icons
- let chargingState = this._proxy.State === UPower.DeviceState.CHARGING
- ? '-charging' : '';
+ let chargingState;
+ if (this._proxy.State === UPower.DeviceState.CHARGING)
+ chargingState = '-charging';
+ else if (this._proxy.State === UPower.DeviceState.PENDING_CHARGE &&
+ this._proxy.ChargeThresholdEnabled)
+ chargingState = '-plugged-in';
+ else
+ chargingState = '';
+
let fillLevel = 10 * Math.floor(this._proxy.Percentage / 10);
const charged =
this._proxy.State === UPower.DeviceState.FULLY_CHARGED ||